package com.huadao.cart_ccs.experiment.addViruses;

import com.huadao.cart_ccs.common.ExperimentStageManager;
import com.huadao.cart_ccs.common.ProjectManager;
import com.huadao.cart_ccs.greendao.GreenDaoManager;
import com.huadao.cart_ccs.greendao.entity.AddViruses;
import com.huadao.cart_ccs.greendao.gen.AddVirusesDao;

import java.util.List;

public class AddVirusesPresenter extends IAddVirusesContract.IAddVirusesPresenter {

    private AddVirusesDao addVirusesDao;
    public AddVirusesPresenter(IAddVirusesContract.IAddVirusesView baseView) {
        attachView(baseView);
        addVirusesDao=GreenDaoManager.getInstance().getSession().getAddVirusesDao();
    }

    @Override
    void getAddVirusesHistory() {
        List<AddViruses> addVirusesList= addVirusesDao.queryBuilder().where(AddVirusesDao.Properties.ProjectId.eq(ProjectManager.getInstance().getProjectId()),AddVirusesDao.Properties.StageId.eq(ExperimentStageManager.getInstance().getStageId())).orderAsc(AddVirusesDao.Properties.StartDate).list();
        baseView.onGetAddVirusesHistory(addVirusesList);
    }

    @Override
    void saveAddViruses(AddViruses addViruses) {
        addVirusesDao.insert(addViruses);
    }
}
